package com.ilop.sthome.data.greenDao;

import com.ilop.sthome.utils.greenDao.converter.DeviceConverter;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;

import java.io.Serializable;
import java.util.List;

/**
 * @author skygge
 * @date 2020-02-17.
 * GitHub：javofxu@github.com
 * email：skygge@yeah.net
 * description：自动化类
 */

@Entity
public class AutomationBean implements Serializable ,Comparable<AutomationBean>{

    static final long serialVersionUID = 42L;

    @Id()
    private String automationOnly;

    private int mid;

    private String sceneId;

    private String name;

    private String code;

    private String deviceName;

    private String crcCord;

    private String reserve;


    @Convert(columnType = String.class, converter = DeviceConverter.class)
    private List<DeviceInfoBean> inputList; //实体类中输入数据

    @Convert(columnType = String.class, converter = DeviceConverter.class)
    private List<DeviceInfoBean> outputList; //实体类中输出数据

    @Generated(hash = 1281790456)
    public AutomationBean(String automationOnly, int mid, String sceneId,
            String name, String code, String deviceName, String crcCord,
            String reserve, List<DeviceInfoBean> inputList,
            List<DeviceInfoBean> outputList) {
        this.automationOnly = automationOnly;
        this.mid = mid;
        this.sceneId = sceneId;
        this.name = name;
        this.code = code;
        this.deviceName = deviceName;
        this.crcCord = crcCord;
        this.reserve = reserve;
        this.inputList = inputList;
        this.outputList = outputList;
    }

    @Generated(hash = 207089853)
    public AutomationBean() {
    }

    public String getAutomationOnly() {
        return this.automationOnly;
    }

    public void setAutomationOnly(String automationOnly) {
        this.automationOnly = automationOnly;
    }

    public int getMid() {
        return this.mid;
    }

    public void setMid(int mid) {
        this.mid = mid;
    }

    public String getSceneId() {
        return this.sceneId;
    }

    public void setSceneId(String sceneId) {
        this.sceneId = sceneId;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCode() {
        return this.code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDeviceName() {
        return this.deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getCrcCord() {
        return this.crcCord;
    }

    public void setCrcCord(String crcCord) {
        this.crcCord = crcCord;
    }

    public String getReserve() {
        return this.reserve;
    }

    public void setReserve(String reserve) {
        this.reserve = reserve;
    }

    public List<DeviceInfoBean> getInputList() {
        return this.inputList;
    }

    public void setInputList(List<DeviceInfoBean> inputList) {
        this.inputList = inputList;
    }

    public List<DeviceInfoBean> getOutputList() {
        return this.outputList;
    }

    public void setOutputList(List<DeviceInfoBean> outputList) {
        this.outputList = outputList;
    }

    @Override
    public int compareTo(AutomationBean o) {
        try{
            int i = Integer.parseInt(this.getCode().substring(30, 32)) - Integer.parseInt(o.getCode().substring(30, 32));
            if (i == 0){
                return Integer.parseInt(this.getCode().substring(32, 34)) - Integer.parseInt(o.getCode().substring(32, 34));
            }
            return i;
        }catch (Exception e){
            return 0;
        }
    }
}
